package ru.spb.xmlreshelper;

import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.spb.xmlreshelper.database.CDTManager;
import ru.spb.xmlreshelper.domain.ICdtService;
import ru.spb.xmlreshelper.screen.RootWindow;

import java.util.Map;

/**
 * @author Nikita.Brazhnikov
 */
public class XmlResHelper {

    private static final Logger logger = LoggerFactory.getLogger("");

	private static Map<Class<?>, Object> registredServices = Maps.newHashMap();

	public static void main(String[] args) {
        logger.info("XmlResHelper started");
		registredServices.put(ICdtService.class, new CDTManager());


		RootWindow.openWindow();
	}

	public static <T> T getService(Class<T> cls) {
		T service = (T) registredServices.get(cls);
		if (service == null)
			throw new RuntimeException("Service " + cls.getName() + " is not registred");
		return service;
	}

}
